package com.laixu.estore.web.controller;

import com.laixu.estore.bean.vo.AddressVo;
import com.laixu.estore.service.AddressService;
import com.laixu.estore.web.response.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Auther: vanse(lc)
 * @Date: 2025/3/10-03-10-17:22
 * @Description：com.briup.estore.web.controller GET 地址栏
 * POST 请求体
 */
@RestController // 前后端分离 json 不返回页面
@RequestMapping("/address")
@RequiredArgsConstructor // lombok
@Slf4j// SLf4j lombok提供的日志对象
public class AddressController {
    private final AddressService addressService;
    @GetMapping
    public Result getAddresses(HttpServletRequest request){
        String userId = (String) request.getAttribute("userId");
        List<AddressVo> list = addressService.findAddresses(Integer.parseInt(userId));
        return  Result.success(list);

    }
}